import { createRouter, createWebHashHistory } from 'vue-router'
// const routes = []
// vue2.0  newVueRouter({}) 创建路由实例
// vue3.0  createRouter({}) 创建路由实例
// const router = createRouter({
  // 使用哈希的路由模式
//   history: createWebHashHistory(),
//   routes
// })
// export default router
const Layout =()=>import ("@/views/Layout")
const Home =()=>import ("@/views/home/index")
const TopCategory =()=>import ("@/views/category/index")
const Subcategory =()=>import ("@/views/category/sub")


const routes = [
  // 一级路由布局容器
  {
    path: '/',
    component:Layout,
    children: [
     {
      path:'/',
      component:Home
     },
     {
       path:"/category/:id",
       component:TopCategory
     },
     {
       path:"/category/sub/:id",
       component:Subcategory
     }
    ]
  }
]
const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
